package com.boomsecret.demo;

import com.boomsecret.domain.CourseDomain;
import org.apache.poi.ss.usermodel.Workbook;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.entity.ExportParams;

import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by wangjinliang on 2018/1/10.
 */
public class ExcelExportDemo {
    public static void main(String[] args) throws Exception {
        List<CourseDomain> domainList = new ArrayList<CourseDomain>();
        domainList.add(new CourseDomain("语文", "tom", 33, "很有趣"));
        domainList.add(new CourseDomain("数学", "jack", 13, "可能有点难"));
        domainList.add(new CourseDomain("C++", "jackson", 133, "我们很有兴趣"));

        ExportParams params = new ExportParams("课程详情", null, "课程详情");
        Workbook workbook = ExcelExportUtil.exportExcel(params, CourseDomain.class, domainList);
        File targetFile = new File("temp.xls");
        FileOutputStream fos = new FileOutputStream(targetFile);
        workbook.write(fos);
        fos.close();
    }
}
